package com.bml.architect.rabbitmq.workqueue;


import com.bml.architect.rabbitmq.utils.RabbitConstant;
import com.bml.architect.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

/**
 * 工作队列模式
 */
public class OrderTicketProductor {

    public static void main(String[] args) throws Exception {
        Connection connection = RabbitUtils.getConnection();
        Channel channel = connection.createChannel();

        channel.queueDeclare(RabbitConstant.simple_queue, false, false, false, null);
        for (int i = 1; i <= 100; i++) {
            String message = String.format("乘客[%d],手机号码[%s],你的车票预定成功", i, "13700001" + i);
            channel.basicPublish("", RabbitConstant.simple_queue, null, message.getBytes());
        }
        channel.close();
        connection.close();

    }
}
